/**
 * @description  : 人员-页签组件
 * @descriptionDetail : 人员-页签组件
 * @copyright    : 浙江烟草
 * @author       : zx
 * @create       : 2022-12-05 10:24:57
 */
<template>
  <view>
    <view class="ordermsg ">

      <mescroll-list :i="0" top="10" :index="0" :load-data="myLoadData" :init-load="false" ref="mescrollItem">
        <view class="re-list" slot-scope="d">
          <!-- <u-swipe-action :index="d.index"  :show="contentList[d.index].showSwipe" @click="deliverClick" @open="deliverOpen" :options="cardOptions"> -->
          <view class="edit-people">
            <u-button shape="circle" class="u-btn" size="mini" type="primary" @click="editPeople(d.data)">编辑</u-button>
          </view>
         
          <people :peopleInfo="d.data"></people>
          <!-- </u-swipe-action> -->
        </view>
      </mescroll-list>

      <view class="popup-submit-btns">
        <u-button class="u-btn" type="primary" @click="addPeople()">新增</u-button>
        <!-- <u-button class="u-btn" type="primary" @click="submitLngLat('02')">提交</u-button> -->
      </view>
    </view>
  </view>
</template>

<script>
// import MeTable from "@/components/me-table.vue";
import fsection from "@/components/form-section";
import mescrollList from "@/components/mescroll_list.vue";
import people from "./people.vue";
import certificateService from "@/service/certificate/certificate.service.js";
export default {
  components: {
    fsection,
    mescrollList,
    people,
    // MeTable
  },
  props: ["retailerUuid"],
  data() {
    return {
      title: {
        basemsg: "人员信息"
      },
      contentList: [],
      cardOptions: [
        {
          text: "编辑",
          style: {
            backgroundColor: "#007aff"
          }
        }
      ]
    };
  },
  mounted() {},
  methods: {
    myLoadData(page) {
      let param = {
        page: page.num,
        limit: page.size,
        retailerUuid: this.retailerUuid
      };
      return new Promise(resolve => {
        certificateService
          .getPersonInfo(param)
          .then(res => {
            if (res.success) {
            //   let list = res.data.map(item => {
            //     return {
            //       ...item,
            //       showSwipe: false
            //     };
            //   });
            //   this.contentList = this.contentList.concat(list);
              resolve({
                totalCount: res.count,
                data: [...res.data]
              });
            } else {
              resolve({
                totalCount: 0,
                data: []
              });
            }
          })
          .catch(e => {
            resolve({
              totalCount: 0,
              data: []
            });
          });
      });
    },
    // deliverClick(index, btnIndex) {
    //   let list = this.$refs.mescrollItem.listDatas;
    //   let processStatus = list[index].status;
    //   this.deliverOpen(99999); // 无论编辑还是删除 都关闭swipe
    //   if (btnIndex == 0) {
    //     // if (processStatus == "00") {
    //     this.$u.route("pages/retailer/retailerInfo/editRetailerInfo", {
    //       retailerUuid: list[index].retailerUuid,
    //       licNo: list[index].licNo
    //     });
    //     // } else {
    //     //   this.$u.toast("当前处于非草稿状态下，不可编辑");
    //     // }
    //   }
    // },
    // deliverOpen(index) {
    //   this.contentList[index] ? (this.contentList[index].showSwipe = true) : "";
    //   this.contentList.map((val, idx) => {
    //     if (index != idx) this.contentList[idx].showSwipe = false;
    //   });
    // },
    addPeople() {
        this.setRouteParam({retailerUuid:this.retailerUuid, isDisabled:false ,isAdd:true});
      this.$u.route("pages/retailer/retailerInfo/retailerItem/componets/addOrEditPeople");
    },
    editPeople(data) {
        this.setRouteParam({ ailerUuid:this.retailerUuid,personUuid:data.personUuid, isDisabled:false ,isAdd:false});
      this.$u.route("pages/retailer/retailerInfo/retailerItem/componets/addOrEditPeople");
    }
  }
};
</script>

<style lang="scss" scoped>
// @import "./retailItem.scss";
@import "style/certificate/common.scss";
.ordermsg {
  position: relative;
  padding: 10rpx 28rpx 10rpx 28rpx;
  margin: 10rpx 0rpx;
  background-color: #fff;
}
.re-list {
  position: relative;
  margin: 20rpx;
  color: #666666;
  font-size: 15px;
  background-color: #fff;
  border-radius: 12px;
  //   padding: 12px;
  // overflow: hidden;
}
.edit-people {
  position: absolute;
  top: 10rpx;
  right: 10rpx;
}
.popup-submit-btns {
  width: calc(100% - 30px);
  position: fixed;
  bottom: 10rpx;
}
.divided-line::deep {
  border-bottom: none;
}
</style>